function showToast(obj = {}){
  const data = Object.assign({
    title: '',
    icon: 'none',
    duration: 3000,
    complete: () => {}
  }, obj)
  uni.showToast(data)
}

function showLoading(obj = {}){
  const data = Object.assign({
    title: '加载中',
    icon: 'none',
    complete: () => {}
  }, obj)
  uni.showLoading(data)
}

function hideLoading(obj = {}){
  uni.hideLoading()
}

function curSymbol(str) {
  var symbol = {
    "RMB": "￥",
    "HKD": "HK$",
    "USD": "$"
  }
  return symbol[str] || '￥'
}

function strip (num, precision = 0) {
  if (precision === 0) { precision = 15; }
  return parseFloat((num * 1).toPrecision(precision));
}

/** 字典翻译 */
function formatDict(cellValue, format = [], fieldNames = {}) {
  const fieldNamesArr = Object.assign({label: 'dictLabel', value: 'dictValue'}, fieldNames)
  const newData = format.find(res => res[fieldNamesArr.value] === cellValue || res[fieldNamesArr.value] * 1 === cellValue)
  return newData ? newData[fieldNamesArr.label] : cellValue
}

export {
  showToast,
  curSymbol,
  showLoading,
  hideLoading,
  strip,
  formatDict
}